home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_aipatrol.cog < prev    next >
Text File  |  1999-11-15  |  1KB  |  71 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_AIPatrol.cog
  4. #
  5. # "patroler" goes back and forth between initial position and a ghost object
  6. #
  7. # [IS]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13.     message    startup
  14.     message    pulse
  15.  
  16.     thing    ghostTarget
  17.     thing    patroler
  18.  
  19.     flex    movespeed=0.75
  20.     flex    thinkRate=1.0
  21.     flex    ctrlocator=0.25
  22.  
  23.     int        direction=-1    local
  24.     vector    position0        local
  25.     vector    position1        local
  26. end
  27.  
  28. # ========================================================================================
  29.  
  30. code
  31. startup:
  32.    AiSetMoveSpeed(patroler, movespeed);
  33.     position0 = GetThingPos(patroler);
  34.     position1 = GetThingPos(ghostTarget);
  35.     SetPulse(thinkRate);
  36.     return;
  37.  
  38. # ........................................................................................
  39.  
  40. pulse:
  41.     if (direction == 1)
  42.     {
  43.         // moving AWAY from initial position
  44.         if (VectorDist(GetThingPos(patroler), position1) < ctrlocator)
  45.         {
  46.             AISetLookPos(patroler, position0);
  47.             AISetMovePos(patroler, position0);
  48.             direction = -1;
  49.         }
  50.     }
  51.     else
  52.     {    
  53.         // moving TOWARDS initial position
  54.         if (VectorDist(GetThingPos(patroler), position0) < ctrlocator)
  55.         {
  56.             AISetLookPos(patroler, position1);
  57.             AISetMovePos(patroler, position1);
  58.             direction = 1;
  59.         }
  60.     }
  61.  
  62.     // check if patroler is dead.
  63.     if (GetThingHealth(patroler) <= 0.0)
  64.     {
  65.         SetPulse(0.0);
  66.     }
  67.     return;
  68.  
  69. end
  70.  
  71.